package com.vanzo.some.interphone;

import android.graphics.Color;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.vanzo.some.R;

import java.util.ArrayList;

/**
 * Created by tisen on 2017/12/25.
 */

public class HomeActivity extends AppCompatActivity {

    private View view;
    private TabLayout tabLayout;
    private ViewPager viewPager;
    private ViewPagerAdapter adapter;

    private ArrayList<Fragment> fragments = new ArrayList<>();
    private ArrayList<TabLayout.Tab> tabs = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        getWindow().setNavigationBarColor(Color.BLUE);
        getSupportActionBar().hide();
        findViewAndSetListener();
    }


    private void findViewAndSetListener() {
        tabLayout = (TabLayout) findViewById(R.id.home_fragment_tab);
        viewPager = (ViewPager) findViewById(R.id.home_fragment_viewPager);
        tabs.add(tabLayout.newTab().setText("连接"));
        tabs.add(tabLayout.newTab().setText("呵呵"));

        fragments.add(new ConnectFragment());
        fragments.add(new SettingFragment());

        adapter = new ViewPagerAdapter(getFragmentManager(), tabs, fragments, this);
        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);
        tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);

        tabLayout.getTabAt(0).setCustomView(R.layout.bottom_item_tab);
        tabLayout.getTabAt(1).setCustomView(R.layout.bottom_item_tab);

    }
}
